home *** CD-ROM | disk | FTP | other *** search
/ DOS Vuser Deluxe 2003 October / DOS Vuser Deluxe 2003 Oct - Disc 1.iso / SKIN / Le Crapouillot.wmz / CrapouillotAnim.JS < prev    next >
Text File  |  2002-02-02  |  17KB  |  464 lines

  1. /*#######################
  2. //initial values
  3. ########################*/
  4. var AMXq = 7;
  5. var debugAMX = false;
  6. var defaultSpriteWidth=110;
  7. var defaultSpriteHeight=110;
  8. var AMXMoveTime = 500;
  9. var AMXtimeoutDecrement = 1;
  10. var AMXinterval = 10;
  11. var mustMaximize = false;
  12.  
  13. /*#######################
  14. //initial sprites creation
  15. ########################*/
  16.  
  17. function setSpriteObjects(){
  18.     printToDebug('setspriteobjects');
  19.     /*
  20.     create the sprites at initial position, state and scenario
  21.     */
  22.     AMXs[0]=new sprite('allScen', 'options_wait_closed',61,41,0,0, 0,0,0);
  23.     AMXs[1]=new sprite('allScen', 'eq_wait_closed',56,164,0,0, 0,0,0);
  24.     AMXs[2]=new sprite('allScen', 'main_steady',35,57,0,0, 0,0,0);
  25.     AMXs[3]=new sprite('allScen', 'rightleg_open',54,158,0,0, 0,0,0);
  26.     //AMXs[4]=new sprite('allScen', 'tail_wait_open',173,54,0, 0,0,0);
  27.     AMXs[4]=new sprite('allScen', 'tail_open',83,144,0, 0,0,0);
  28.     AMXs[5]=new sprite('allScen', 'leftleg_open',84,198,0,0, 0,0,0);
  29.     AMXs[6]=new sprite('allScen', 'playlist_wait_closed',130,200,0,0, 0,0,0);
  30.     printToDebug('setspriteobjects done');
  31. }
  32.  
  33.     
  34. /*#######################
  35. //states & scenarios definition
  36. ########################*/
  37. function initStates(){
  38.     printToDebug('initstates');
  39.     /*
  40.     defines the different states and scenarios
  41.     */
  42.  
  43.     states = new Array;
  44.     
  45.     /*##########
  46.     allScen state - each state has several scenarios
  47.     ###########*/
  48.     /*    allScen    */
  49.     st_n = "allScen";
  50.     states[ st_n] = new state;
  51.     states[ st_n].onErrorScenario = "options_wait_closed";
  52.     states[ st_n].z = 3;
  53.     states[ st_n].absolutePos = true;
  54.  
  55.  
  56.     states[ st_n ].scenarios["options_open"] = new scenario;
  57.     with (states[ st_n ].scenarios["options_open"]) {
  58.     random_delay = 0;
  59.     steps[0] = new step( st_n, "OPTIONS.gif", 20, 18, 11);
  60.     next_scenarios[0] = new next_scenario("options_wait_open",1);
  61.     next_states[0] = new next_state("allScen", "options_wait_open", 1);
  62.     }
  63.  
  64.     states[ st_n ].scenarios["options_close"] = new scenario;
  65.     with (states[ st_n ].scenarios["options_close"]) {
  66.     random_delay = 0;
  67.     steps[0] = new step( st_n, "OPTIONS.gif", 61, 91, 11);
  68.     next_scenarios[0] = new next_scenario("options_wait_closed",1);
  69.     next_states[0] = new next_state("allScen", "options_wait_closed", 1);
  70.     }
  71.  
  72.     states[ st_n ].scenarios["options_wait_open"] = new scenario;
  73.     with (states[ st_n ].scenarios["options_wait_open"]) {
  74.     random_delay = 0;
  75.     steps[0] = new step( st_n, "OPTIONS.gif", 20, 18, 510);
  76.     next_scenarios[0] = new next_scenario("options_close",1);
  77.     next_states[0] = new next_state("allScen", "options_close", 1);
  78.     }
  79.  
  80.     states[ st_n ].scenarios["options_wait_closed"] = new scenario;
  81.     with (states[ st_n ].scenarios["options_wait_closed"]) {
  82.     random_delay = 0;
  83.     steps[0] = new step( st_n, "OPTIONS.gif", 61, 91, 20000);
  84.     next_scenarios[0] = new next_scenario("options_wait_closed",1);
  85.     next_states[0] = new next_state("allScen", "options_wait_closed", 1);
  86.     onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
  87.     onmouseover_zones[0].next_states[0] = new next_state("allScen", "options_open", 50);
  88.     }
  89.  
  90.     states[ st_n ].scenarios["eq_open"] = new scenario;
  91.     with (states[ st_n ].scenarios["eq_open"]) {
  92.     random_delay = 0;
  93.     steps[0] = new step( st_n, "eq.gif", 170, 170, 11);
  94.     next_scenarios[0] = new next_scenario("eq_wait_open",1);
  95.     next_states[0] = new next_state("allScen", "eq_wait_open", 1);
  96.     }
  97.  
  98.     states[ st_n ].scenarios["eq_close"] = new scenario;
  99.     with (states[ st_n ].scenarios["eq_close"]) {
  100.     random_delay = 0;
  101.     steps[0] = new step( st_n, "eq.gif", 56, 164, 11);
  102.     next_scenarios[0] = new next_scenario("eq_wait_closed",1);
  103.     next_states[0] = new next_state("allScen", "eq_wait_closed", 1);
  104.     }
  105.  
  106.     states[ st_n ].scenarios["eq_wait_open"] = new scenario;
  107.     with (states[ st_n ].scenarios["eq_wait_open"]) {
  108.     random_delay = 0;
  109.     steps[0] = new step( st_n, "eq.gif", 170, 170, 510);
  110.     next_scenarios[0] = new next_scenario("eq_close",1);
  111.     next_states[0] = new next_state("allScen", "eq_close", 1);
  112.     next_states[0].action="closePlaylist();";
  113.     }
  114.  
  115.     states[ st_n ].scenarios["eq_wait_closed"] = new scenario;
  116.     with (states[ st_n ].scenarios["eq_wait_closed"]) {
  117.     random_delay = 0;
  118.     steps[0] = new step( st_n, "eq.gif", 56, 164, 20000);
  119.     next_scenarios[0] = new next_scenario("eq_wait_closed",1);
  120.     next_states[0] = new next_state("allScen", "eq_wait_closed", 1);
  121.     }
  122.  
  123.     states[ st_n ].scenarios["main_steady"] = new scenario;
  124.     with (states[ st_n ].scenarios["main_steady"]) {
  125.     random_delay = 0;
  126.     steps[0] = new step( st_n, "crapouillot.gif", 35, 107, 20000);
  127.     next_scenarios[0] = new next_scenario("main_steady",1);
  128.     next_states[0] = new next_state("allScen", "main_steady", 1);
  129.     }
  130.  
  131.     states[ st_n ].scenarios["main_moving"] = new scenario;
  132.     with (states[ st_n ].scenarios["main_moving"]) {
  133.     random_delay = 0;
  134.     steps[0] = new step( st_n, "crapouillot.gif", 35, 107, 200);
  135.     steps[1] = new step( st_n, "crapouillot-geckofeeling.gif", 35, 107, 200);
  136.     next_scenarios[0] = new next_scenario("main_steady",1);
  137.     next_states[0] = new next_state("allScen", "main_steady", 1);
  138.     next_states[0].action="eyeHoverControl.visible='true';";
  139.     }
  140.  
  141.     states[ st_n ].scenarios["rightleg_wait_open"] = new scenario;
  142.     with (states[ st_n ].scenarios["rightleg_wait_open"]) {
  143.     random_delay = 0;
  144.     steps[0] = new step( st_n, "RIGHTLEG.gif", 4, 158, 120);
  145.     next_scenarios[0] = new next_scenario("rightleg_wait_open",1);
  146.     next_scenarios[1] = new next_scenario("rightleg_closeboth",2);
  147.     next_states[0] = new next_state("allScen", "rightleg_wait_open", 1);
  148.     }
  149.  
  150.     states[ st_n ].scenarios["rightleg_closeboth"] = new scenario;
  151.     with (states[ st_n ].scenarios["rightleg_closeboth"]) {
  152.     random_delay = 0;
  153.     steps[0] = new step( st_n, "RIGHTLEG.gif", 4, 158, 0);
  154.     next_scenarios[0] = new next_scenario("rightleg_close",1);
  155.     next_states[0] = new next_state("allScen", "rightleg_close", 1);
  156.     next_states[0].action = "closeLeftLeg();";
  157.     }
  158.  
  159.     states[ st_n ].scenarios["rightleg_open"] = new scenario;
  160.     with (states[ st_n ].scenarios["rightleg_open"]) {
  161.     random_delay = 0;
  162.     steps[0] = new step( st_n, "RIGHTLEG.gif", 54, 158, 1);
  163.     steps[1] = new step( st_n, "RIGHTLEG.gif", 54, 158, 10);
  164.     next_scenarios[0] = new next_scenario("rightleg_wait_open",1);
  165.     next_states[0] = new next_state("allScen", "rightleg_wait_open", 1);
  166.     }
  167.  
  168.     states[ st_n ].scenarios["rightleg_openboth"] = new scenario;
  169.     with (states[ st_n ].scenarios["rightleg_openboth"]) {
  170.     random_delay = 0;
  171.     steps[0] = new step( st_n, "RIGHTLEG.gif", 54, 158, 0);
  172.     next_scenarios[0] = new next_scenario("rightleg_wait_open",1);
  173.     next_states[0] = new next_state("allScen", "rightleg_wait_open", 1);
  174.     next_states[0].action="openLeftLeg();";
  175.     }
  176.  
  177.     states[ st_n ].scenarios["rightleg_close"] = new scenario;
  178.     with (states[ st_n ].scenarios["rightleg_close"]) {
  179.     random_delay = 0;
  180.     steps[0] = new step( st_n, "RIGHTLEG.gif", 54, 158, 1);
  181.     next_scenarios[0] = new next_scenario("rightleg_wait_closed",1);
  182.     next_states[0] = new next_state("allScen", "rightleg_wait_closed", 1);
  183.     }
  184.  
  185.     states[ st_n ].scenarios["rightleg_wait_closed"] = new scenario;
  186.     with (states[ st_n ].scenarios["rightleg_wait_closed"]) {
  187.     random_delay = 0;
  188.     steps[0] = new step( st_n, "RIGHTLEG.gif", 54, 158, 1000);
  189.     next_scenarios[0] = new next_scenario("rightleg_wait_closed",3);
  190.     next_scenarios[1] = new next_scenario("rightleg_openboth",1);
  191.     next_states[0] = new next_state("allScen", "rightleg_wait_closed", 1);
  192.     }
  193.  
  194.     states[ st_n ].scenarios["leftleg_wait_open"] = new scenario;
  195.     with (states[ st_n ].scenarios["leftleg_wait_open"]) {
  196.     random_delay = 0;
  197.     steps[0] = new step( st_n, "LEFTLEG.gif", 84, 248, 10000);
  198.     next_scenarios[0] = new next_scenario("leftleg_wait_open",1);
  199.     next_states[0] = new next_state("allScen", "leftleg_wait_open", 1);
  200.     }
  201.  
  202.     states[ st_n ].scenarios["leftleg_open"] = new scenario;
  203.     with (states[ st_n ].scenarios["leftleg_open"]) {
  204.     random_delay = 0;
  205.     steps[0] = new step( st_n, "LEFTLEG.gif", 84, 198, 1);
  206.     steps[1] = new step( st_n, "LEFTLEG.gif", 84, 198, 10);
  207.     next_scenarios[0] = new next_scenario("leftleg_wait_open",1);
  208.     next_states[0] = new next_state("allScen", "leftleg_wait_open", 1);
  209.     }
  210.  
  211.     states[ st_n ].scenarios["leftleg_close"] = new scenario;
  212.     with (states[ st_n ].scenarios["leftleg_close"]) {
  213.     random_delay = 0;
  214.     steps[0] = new step( st_n, "LEFTLEG.gif", 84, 198, 1);
  215.     next_scenarios[0] = new next_scenario("leftleg_wait_closed",1);
  216.     next_states[0] = new next_state("allScen", "leftleg_wait_closed", 1);
  217.     }
  218.  
  219.     states[ st_n ].scenarios["leftleg_wait_closed"] = new scenario;
  220.     with (states[ st_n ].scenarios["leftleg_wait_closed"]) {
  221.     random_delay = 0;
  222.     steps[0] = new step( st_n, "LEFTLEG.gif", 84, 198, 10000);
  223.     next_scenarios[0] = new next_scenario("leftleg_wait_closed",1);
  224.     next_states[0] = new next_state("allScen", "leftleg_wait_closed", 1);
  225.     }
  226.  
  227.     states[ st_n ].scenarios["tail_wait_open"] = new scenario;
  228.     with (states[ st_n ].scenarios["tail_wait_open"]) {
  229.     random_delay = 0;
  230.     steps[0] = new step( st_n, "TAIL.gif", 173, 54, 400);
  231.     next_scenarios[0] = new next_scenario("tail_wait_open",10);
  232.     next_scenarios[1] = new next_scenario("tail_wait_closed",1);
  233.     next_scenarios[2] = new next_scenario("tail_jiggle",2);
  234.     next_states[0] = new next_state("allScen", "tail_wait_open", 1);
  235.     }
  236.  
  237.     states[ st_n ].scenarios["tail_wait_closed"] = new scenario;
  238.     with (states[ st_n ].scenarios["tail_wait_closed"]) {
  239.     random_delay = 0;
  240.     steps[0] = new step( st_n, "TAIL.gif", 83, 144, 100);
  241.     next_scenarios[0] = new next_scenario("tail_wait_closed",1);
  242.     next_scenarios[1] = new next_scenario("tail_open",2);
  243.     next_states[0] = new next_state("allScen", "tail_wait_closed", 1);
  244.     }
  245.  
  246.     states[ st_n ].scenarios["tail_jiggle"] = new scenario;
  247.     with (states[ st_n ].scenarios["tail_jiggle"]) {
  248.     random_delay = 1;
  249.     steps[0] = new step( st_n, "TAIL.gif", 173, 54, 10);
  250.     steps[1] = new step( st_n, "TAIL2.gif", 173, 54, 1);
  251.     steps[2] = new step( st_n, "TAIL3.gif", 173, 54, 1);
  252.     steps[3] = new step( st_n, "TAIL2.gif", 173, 54, 3);
  253.     steps[4] = new step( st_n, "TAIL.gif", 173, 54, 20);
  254.     next_scenarios[0] = new next_scenario("tail_jiggle",2);
  255.     next_scenarios[1] = new next_scenario("tail_wait_open",1);
  256.     next_states[0] = new next_state("allScen", "tail_wait_open", 2);
  257.     }
  258.  
  259.     states[ st_n ].scenarios["tail_open"] = new scenario;
  260.     with (states[ st_n ].scenarios["tail_open"]) {
  261.     random_delay = 1;
  262.     steps[0] = new step( st_n, "TAIL3.gif", 158, 69, 12);
  263.     steps[1] = new step( st_n, "TAIL.gif", 163, 64, 9);
  264.     steps[2] = new step( st_n, "TAIL2.gif", 168, 59, 1);
  265.     steps[3] = new step( st_n, "TAIL3.gif", 173, 54, 3);
  266.     next_scenarios[0] = new next_scenario("tail_jiggle",2);
  267.     next_scenarios[1] = new next_scenario("tail_wait_open",1);
  268.     next_states[0] = new next_state("allScen", "tail_wait_open", 1);
  269.     }
  270.  
  271.     states[ st_n ].scenarios["playlist_wait_closed"] = new scenario;
  272.     with (states[ st_n ].scenarios["playlist_wait_closed"]) {
  273.     random_delay = 0;
  274.     steps[0] = new step( st_n, "PlayListBG.gif", 130, 200, 20000);
  275.     next_scenarios[0] = new next_scenario("playlist_wait_closed",1);
  276.     next_states[0] = new next_state("allScen", "playlist_wait_closed", 1);
  277.     }
  278.  
  279.     states[ st_n ].scenarios["playlist_o1"] = new scenario;
  280.     with (states[ st_n ].scenarios["playlist_o1"]) {
  281.     random_delay = 0;
  282.     steps[0] = new step( st_n, "PlayListBG.gif", 130, 200, 10);
  283.     next_scenarios[0] = new next_scenario("playlist_o2",1);
  284.     next_states[0] = new next_state("allScen", "playlist_o2", 1);
  285.     next_states[0].action="AMXSubviewSprite6.height='30';AMXSubviewSprite6.visible='true';";
  286.     }
  287.  
  288.     states[ st_n ].scenarios["playlist_o2"] = new scenario;
  289.     with (states[ st_n ].scenarios["playlist_o2"]) {
  290.     random_delay = 0;
  291.     steps[0] = new step( st_n, "PlayListBG.gif", 130, 200, 0);
  292.     next_scenarios[0] = new next_scenario("playlist_o3",1);
  293.     next_states[0] = new next_state("allScen", "playlist_o3", 1);
  294.     next_states[0].action="AMXSubviewSprite6.height='60';";
  295.     }
  296.  
  297.     states[ st_n ].scenarios["playlist_o3"] = new scenario;
  298.     with (states[ st_n ].scenarios["playlist_o3"]) {
  299.     random_delay = 0;
  300.     steps[0] = new step( st_n, "PlayListBG.gif", 130, 200, 0);
  301.     next_scenarios[0] = new next_scenario("playlist_o4",1);
  302.     next_states[0] = new next_state("allScen", "playlist_o4", 1);
  303.     next_states[0].action="AMXSubviewSprite6.height='90';";
  304.     }
  305.  
  306.     states[ st_n ].scenarios["playlist_o4"] = new scenario;
  307.     with (states[ st_n ].scenarios["playlist_o4"]) {
  308.     random_delay = 0;
  309.     steps[0] = new step( st_n, "PlayListBG.gif", 130, 200, 0);
  310.     next_scenarios[0] = new next_scenario("playlist_o5",1);
  311.     next_states[0] = new next_state("allScen", "playlist_o5", 1);
  312.     next_states[0].action="AMXSubviewSprite6.height='140';";
  313.     }
  314.  
  315.     states[ st_n ].scenarios["playlist_o5"] = new scenario;
  316.     with (states[ st_n ].scenarios["playlist_o5"]) {
  317.     random_delay = 0;
  318.     steps[0] = new step( st_n, "PlayListBG.gif", 130, 200, 1);
  319.     next_scenarios[0] = new next_scenario("playlist_o6",1);
  320.     next_states[0] = new next_state("allScen", "playlist_o6", 1);
  321.     next_states[0].action="AMXSubviewSprite6.height='160';";
  322.     }
  323.  
  324.     states[ st_n ].scenarios["playlist_o6"] = new scenario;
  325.     with (states[ st_n ].scenarios["playlist_o6"]) {
  326.     random_delay = 0;
  327.     steps[0] = new step( st_n, "PlayListBG.gif", 130, 200, 2);
  328.     next_scenarios[0] = new next_scenario("playlist_wait_open",1);
  329.     next_states[0] = new next_state("allScen", "playlist_wait_open", 1);
  330.     next_states[0].action="AMXSubviewSprite6.height='175';pl.visible='true';";
  331.     }
  332.  
  333.     states[ st_n ].scenarios["playlist_wait_open"] = new scenario;
  334.     with (states[ st_n ].scenarios["playlist_wait_open"]) {
  335.     random_delay = 0;
  336.     steps[0] = new step( st_n, "PlayListBG.gif", 130, 200, 20000);
  337.     next_scenarios[0] = new next_scenario("playlist_wait_open",1);
  338.     next_states[0] = new next_state("allScen", "playlist_wait_open", 1);
  339.     }
  340.  
  341.  
  342.  
  343.  
  344.  
  345. }
  346.  
  347.  
  348. /*#######################
  349. //custom functions
  350. ########################*/
  351.  
  352. function switchScenarioNow(AMXid,scenarioName) {
  353.     if (AMXs[AMXid].status.current_scenario_name == scenarioName) {
  354.     } else {
  355.         AMXs[AMXid].status.current_scenario_name = scenarioName;
  356.         AMXs[AMXid].status.step_no = -1 ;
  357.         AMXs[AMXid].status.timeout = 0 ;
  358.     }
  359. }
  360.  
  361.  
  362. function openOptions() {
  363.     if(AMXs[0].status.current_scenario_name=="options_wait_open") {
  364.         switchScenarioNow(0,"options_close");
  365.     } else {
  366.         switchScenarioNow(0,"options_open");
  367.     }
  368.     
  369. }
  370.  
  371. function openPlaylist() {
  372.     switchScenarioNow(6,"playlist_o1");
  373. }
  374.  
  375. function closePlaylist() {
  376.     switchScenarioNow(6,"playlist_wait_closed");
  377.     pl.visible="false";
  378.     AMXSubviewSprite6.visible='false';
  379. }
  380.  
  381. function closeOptions() {
  382.     switchScenarioNow(0,"options_close");
  383. }
  384.  
  385. function openCloseEQ() {
  386.     if(AMXs[1].status.current_scenario_name=="eq_wait_open") {
  387.         closeEQ();
  388.     } else {
  389.         openEQ();
  390.     }
  391. }
  392.  
  393. function openEQ() {
  394.     switchScenarioNow(1,"eq_open");
  395.     mainView.width="450";
  396.     mainView.height="400";
  397. }
  398.  
  399. function closeEQ() {
  400.     switchScenarioNow(1,"eq_close");
  401.     closePlaylist();
  402. }
  403.  
  404. function openCloseAll() {
  405.     if (geckosState==0) return;
  406.     if ( ( (geckosState==2) || (geckosState==3) ) && (AMXrnd()>0.3) ) return;
  407.     if (isOpen) {
  408.         closeAll();
  409.         isOpen=false;
  410.     } else {
  411.         openAll();
  412.         isOpen=true;
  413.     }
  414. }
  415.  
  416. function openAll() {
  417.     switchScenarioNow(0,"options_open");
  418.     openEQ();
  419.     switchScenarioNow(3,"rightleg_wait_open");
  420.     switchScenarioNow(4,"tail_jiggle");
  421.     switchScenarioNow(5,"leftleg_wait_open");
  422. }
  423.  
  424. function closeAll() {
  425.     switchScenarioNow(0,"options_close");
  426.     switchScenarioNow(1,"eq_close");
  427.     switchScenarioNow(3,"rightleg_wait_closed");
  428.     switchScenarioNow(4,"tail_wait_closed");
  429.     switchScenarioNow(5,"leftleg_wait_closed");
  430. }
  431.  
  432. function closeLeftLeg() {
  433.     switchScenarioNow(5,"leftleg_close");
  434. }
  435.  
  436. function openLeftLeg() {
  437.     switchScenarioNow(5,"leftleg_wait_open");
  438. }
  439.  
  440. function closeRightLeg() {
  441.     switchScenarioNow(3,"rightleg_close");
  442. }
  443.  
  444. function openRightLeg() {
  445.     switchScenarioNow(3,"rightleg_wait_open");
  446. }
  447.  
  448. function activeCrapouillot(){
  449.     if (geckosState==0 ) return;
  450.     if (geckosState==3 && AMXrnd()>.3 ) return;
  451.     openLeftLeg();
  452.     openRightLeg();
  453. }
  454.  
  455. function animateEye() {
  456.     if (AMXs[2].status.current_scenario_name != "main_moving") {
  457.         eyeHoverControl.visible="false";
  458.         switchScenarioNow(2,"main_moving");
  459.     }
  460. }
  461.  
  462. function animateTail() {
  463.     switchScenarioNow(4,"tail_jiggle");
  464. }